/** * @author  wangyin: 
    * @date    2015年10月28日 下午12:34:22
    */
package com.ecp.templet;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.ecp.commons.Global;
import com.ecp.commons.bean.Column;
import com.ecp.commons.service.ColumnService;

@Controller
public class FooterController {
	private final String	successView	= "/front/commPart/footer";

	@Autowired
	ColumnService			columnService;

	@RequestMapping("/footer.do")
	public ModelAndView getFooterHelp(HttpServletRequest req, HttpServletResponse resp)
			throws JSONException {

		Map<String, Object> model = new HashMap<String, Object>();

		//判断是否为迷你
		if ("yes".equals(req.getParameter("isMini"))) {
			model.put("isMini", "yes");
			return new ModelAndView(this.successView, model);
		}
		model.put("isMini", "no");

		//加入页脚帮助中心
		List<Column> helpData = columnService.getColumnByParentIdAndIsFrontShow(
				Global.PAGE_END_NAVIGATION, Global.FRONT_SHOW_YES, "COLORDER asc");
		List<Map<String, Object>> helpData2 = new ArrayList<Map<String, Object>>();
		List<Column> ls = null;
		Map<String, Object> o = null;
		for (Column c : helpData) {
			ls = columnService.getColumnByParentIdAndIsFrontShow(c.getId(), Global.FRONT_SHOW_YES,
					"COLORDER asc");
			o = new HashMap<String, Object>();
			o.put("option", c);
			o.put("children", ls);
			helpData2.add(o);
		}

		model.put("helpData2", helpData2);
		return new ModelAndView(this.successView, model);
	}
}
